export function musicTime(time: number | undefined): string {
  if (!time) return "";
  const date = new Date(time);
  const year = date.getFullYear();
  let month: string | number = date.getMonth() + 1;
  let day: string | number = date.getDate();
  month = month >= 10 ? month : "0" + month;
  day = day >= 10 ? day : "0" + day;
  return `${year}.${month}.${day}`;
}

// ms: 12:24
export function musicDurationTime(time: number) {
  var time = time / 1000;
  var minute = Math.floor(time / 60);
  var second = Math.floor(time % 60);
  return padLeftZero(minute) + ":" + padLeftZero(second);
}

function padLeftZero(time: number) {
  var timer = time + "";
  return ("00" + timer).slice(timer.length);
}
